/**
 * Filename: HeaderSpanSizeLookup.java
 * @author  Firefly
 * @contact postfirefly@163.com
 * @time    2016/4/18 15:10
 */
package com.github.postsanf.yinian.ynlist;
import android.support.v7.widget.GridLayoutManager;

public class HeaderSpanSizeLookup extends GridLayoutManager.SpanSizeLookup {

	private YNRecyclerViewAdapter adapter;
	private int mSpanSize = 1;

	public HeaderSpanSizeLookup(YNRecyclerViewAdapter adapter, int spanSize) {
		this.adapter = adapter;
		this.mSpanSize = spanSize;
	}

	@Override
	public int getSpanSize(int position) {
		boolean isHeaderOrFooter = adapter.isHeader(position) || adapter.isFooter(position);
		return isHeaderOrFooter ? mSpanSize : 1;
	}
}